<!DOCTYPE html>
<html>
<head>
    <title>工作日志填写</title>
    <%include("/app/resapi/mobilestyle.html"){}%>
    <style type="text/css">
        .list-item {
            height: 100px;
        }
    </style>
</head>
<body>
<div align="left" style="width:100%;text-align: center">
    <a href="/mobile/diary/index" class="btn btn-default">日志列表</a>
    <a href="/mobile/diary/add" class="btn btn-purple">填写日志</a>
</div>
<section class="g-flexview">
    <section class="g-scrollview">
        <div class="m-cell">
            <div class="cell-item">
                <div class="cell-left">指定日期：</div>
                <div class="cell-right"><input id="diaryDay" class="cell-input" type="date" value="" placeholder=""></div>
            </div>
            <div class="cell-item">
                <div class="cell-left">日志标题：</div>
                <div class="cell-right"><input id="title" type="text" class="cell-input" placeholder="请输日志标题"></div>
            </div>
            <div class="cell-item">
                <div class="cell-left">日志类型：</div>
                <label class="cell-right cell-arrow">
                    <select class="cell-select" id="diaryType">
                        <option value="1">部门工作汇报</option>
                        <option value="2">个人工作日志</option>
                    </select>
                </label>
            </div>
            <div class="cell-item" style="padding: 0.24rem;">
                <textarea class="form-control" rows="5" id="content"></textarea>
            </div>
            <div class="cell-item">
                <div class="cell-left">日志附件：</div>
                <div class="cell-right">
                    <div id="show_diaryattach"></div>
                    <a class="addfile" href="javascript:void(0)">${i18n('fileupload')} <input data_value="" type="file" onchange="fileUpLoad('diary','diaryattach');" hidefocus="true" size="1" id="diaryattach"
                                                                                              name="diaryattach" class="addfile" multiple="multiple"></a>

                </div>
            </div>
            <div class="cell-item">
                <div class="cell-left">附件权限：</div>
                <div class="cell-right">
                    <div class="control-group">
                        <label>
                            <input type="radio" class="colored-danger" value="1" name="attachPriv" checked="checked" data-bv-field="attachPriv"> <span class="text">在线阅读</span>
                        </label>
                        <label>
                            <input type="radio" class="colored-danger" value="3" name="attachPriv" data-bv-field="attachPriv"> <span class="text">允许下载</span>
                        </label>
                        <label>
                            <input type="radio" class="colored-danger" value="2" name="attachPriv" data-bv-field="attachPriv"> <span class="text">允许打印</span>
                        </label>
                    </div>
                </div>
            </div>
            <div class="cell-item" style="margin-top: 20px;padding: 0.24rem;padding-bottom: 20px;" align="center">
                <a href="javascript:void(0);" class="btn btn-sky shiny js-save" style="width:100%">${i18n('save')}</a>
            </div>
        </div>
    </section>
</section>

<%include("/app/resapi/mobilejs.html"){}%>
<script type="text/javascript" src="/module/fileupload/ajaxfileupload.js"></script>
<script type="text/javascript" src="/module/fileupload/mobilefileupload.js"></script>
<script>
    $(function () {
        $(".js-save").unbind("click").click(function () {
            insertDiary();
        })
    })

    function insertDiary() {
        $.ajax({
            url: "/set/oaset/sendDiary",
            type: "post",
            dataType: "json",
            data: {
                diaryDay: $("#diaryDay").val(),
                title: $("#title").val(),
                diaryType: $("#diaryType").val(),
                content: $("#content").val(),
                attach: $("#diaryattach").attr("data_value"),
                attachPriv: $("input:radio[name='attachPriv']:checked").val()
            },
            success: function (data) {
                if (data.status == "200") {
                    window.location.reload();
                } else if (data.status == "100") {
                    layer.msg(data.msg);
                } else {
                    console.log(data.msg);
                }
            }
        });
    }
</script>
</body>
</html>
